#include "stdio.h"
#include "sqlext.h"
#include "sql.h"
#include "vector"
#pragma once
using namespace std;

typedef struct _AutoVar
{
	int type;
	int index;
	int len;
	void* ptr;
}AutoVar;
class DataRecord
{
private:
	SQLHANDLE m_hData;
	int m_NumRows;
	vector<AutoVar> m_AutoVar;
	vector<AutoVar> m_AutoVarData;
public:
	DataRecord(SQLHANDLE hSQL);
	~DataRecord();
	int GetNextRecord();
	int SetDataContainer();
	int InitFields();
	int GetRecordCount();
	AutoVar* GetValueByIndex(int index);
	AutoVar* GetValueByName(char* pName);

};

class DataEngine
{
public:
	DataEngine();
	int InitDatabase();
	int GetRecord();
	int IoQuery(const char* sqlquery);
	DataRecord* DataQuery(const char* sqlquery);
	int Get_Last_Insert_ID();
private:
	SQLHANDLE m_hEnv;
	SQLHANDLE m_hDBC;
};